package com.kushe.entity;

import com.kushe.util.core.DbUtils;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;

import java.util.Date;

/**
 * Created by WhiteBlue on 15/5/8.
 */
@Table("ks_message")
public class Message {

    @Id
    private int id;

    @Column
    private int from_id;

    @Column
    private int to_id;

    @Column
    private boolean read_A;

    @Column
    private boolean read_B;

    @Column
    private Date time;

    @One(target = User.class, field = "to_id")
    private User to_user;

    @One(target = User.class, field = "from_id")
    private User from_user;

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getFrom_id() {
        return from_id;
    }

    public void setFrom_id(int from_id) {
        this.from_id = from_id;
    }

    public int getTo_id() {
        return to_id;
    }

    public void setTo_id(int to_id) {
        this.to_id = to_id;
    }

    public boolean isRead_A() {
        return read_A;
    }

    public void setRead_A(boolean read_A) {
        this.read_A = read_A;
    }

    public boolean isRead_B() {
        return read_B;
    }

    public void setRead_B(boolean read_B) {
        this.read_B = read_B;
    }

    public User getTo_user() {
        if (this.to_user == null) {
            DbUtils.getNutzDao().fetchLinks(this, "to_user");
            return this.to_user;
        } else
            return this.to_user;
    }

    public void setTo_user(User to_user) {
        this.to_user = to_user;
    }

    public User getFrom_user() {
        if (this.from_user == null) {
            DbUtils.getNutzDao().fetchLinks(this, "from_user");
            return this.from_user;
        } else
            return this.from_user;
    }

    public void setFrom_user(User from_user) {
        this.from_user = from_user;
    }
}
